package com.cbd.controller;


import com.cbd.dto.UserEmailDto;
import com.cbd.service.IEmailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author BingBing
 * @desc  邮件发送控制器
 * @date 2024/11/21 14:26
 */
@RestController//接受请求
@CrossOrigin //解决跨域
@Slf4j //日志
@RequestMapping("/email") //访问路径
@Api(tags = "邮件发送接口")
public class EmailController{

    //注入对象
    @Resource
    private IEmailService emailService;

    @PostMapping ("/sendEmail")
    @ApiOperation(value = "发送邮件", notes = "发送邮件接口")
    public String sendEmail(UserEmailDto user){
        log.info("发送邮件......");
        return emailService.sendEmail(user);
    }

    @PostMapping("/verificationEmail")
    @ApiOperation(value = "开始验证", notes = "开始验证接口")
    public String verificationEmail(UserEmailDto user){
        log.info("验证-邮箱发送的验证码......");
        return emailService.verificationEmail(user);
    }
}
